package com.example.common.config;

import jakarta.annotation.Resource;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Resource
    private JWTInterceptor jwtInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(jwtInterceptor).addPathPatterns("/**")
                .excludePathPatterns("/")
                .excludePathPatterns("/login", "/register", "/files/**",
                        "/notice/selectPage", "/banner/selectPage",
                        "/category/selectPage", "/goods/**", "/score/**",
                        "/wxLogin/**", "/user/**", "/avatar/selectPage",
                        "/comments/**", "/posts/**",
                        "/download/**", "/doc.html",
                        "/doc/**", "/webjars/**",
                        "/v3/api-docs/**", "/swagger-ui/**",
                        "/swagger-ui.html", "/favicon.ico"
                );
    }

}
